﻿using AuthTemplate.Entity;
using AuthTemplate.Repository.Mapping;
using MySql.Data.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuthTemplate.Repository
{
    public class AuthTemplateDBContext:DbContext
    {
        static AuthTemplateDBContext()
        {
            //从不创建数据库
            Database.SetInitializer<AuthTemplateDBContext>(null);
        }

        public AuthTemplateDBContext()
            :base("Name = AuthTemplateDBContext")
        { }

        #region Entity Sets
        public System.Data.Entity.DbSet<Application> Applications { get; set; }
        public System.Data.Entity.DbSet<Category> Categories { get; set; }
        public System.Data.Entity.DbSet<CategoryType> CategoryTypes { get; set; }
        public System.Data.Entity.DbSet<FlowInstance> FlowInstances { get; set; }
        public System.Data.Entity.DbSet<FlowInstanceOperationHistory> FlowInstanceOperationHistories { get; set; }
        public System.Data.Entity.DbSet<FlowInstanceTransitionHistory> FlowInstanceTransitionHistories { get; set; }
        public System.Data.Entity.DbSet<FlowScheme> FlowSchemes { get; set; }
        public System.Data.Entity.DbSet<Form> Forms { get; set; }
        public System.Data.Entity.DbSet<FormQINGJIA> FormQINGJIAs { get; set; }
        public System.Data.Entity.DbSet<Module> Modules { get; set; }
        public System.Data.Entity.DbSet<ModuleElement> ModuleElements { get; set; }
        public System.Data.Entity.DbSet<Org> Orgs { get; set; }
        public System.Data.Entity.DbSet<Relevance> Relevances { get; set; }
        public System.Data.Entity.DbSet<Resource> Resources { get; set; }
        public System.Data.Entity.DbSet<Role> Roles { get; set; }
        public System.Data.Entity.DbSet<Stock> Stocks { get; set; }
        public System.Data.Entity.DbSet<User> Users { get; set; }

        public System.Data.Entity.DbSet<StudentCash> StudentCashs { get; set; }

        public System.Data.Entity.DbSet<StudentInfo> StudentInfos { get; set; }

        #endregion

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new ApplicationMap());
            modelBuilder.Configurations.Add(new CategoryMap());
            modelBuilder.Configurations.Add(new CategoryTypeMap());
            modelBuilder.Configurations.Add(new FlowInstanceMap());
            modelBuilder.Configurations.Add(new FlowInstanceOperationHistoryMap());
            modelBuilder.Configurations.Add(new FlowInstanceTransitionHistoryMap());
            modelBuilder.Configurations.Add(new FlowSchemeMap());
            modelBuilder.Configurations.Add(new FormMap());
            modelBuilder.Configurations.Add(new FormQINGJIAMap());
            modelBuilder.Configurations.Add(new ModuleMap());
            modelBuilder.Configurations.Add(new ModuleElementMap());
            modelBuilder.Configurations.Add(new OrgMap());
            modelBuilder.Configurations.Add(new RelevanceMap());
            modelBuilder.Configurations.Add(new ResourceMap());
            modelBuilder.Configurations.Add(new RoleMap());
            modelBuilder.Configurations.Add(new StockMap());
            modelBuilder.Configurations.Add(new UserMap());
            modelBuilder.Configurations.Add(new StudentCashMap());
            modelBuilder.Configurations.Add(new StudentInfoMap());
        }

    }
}
